package com.interauto.Dao.Mapper;

import com.interauto.Dao.entity.Caserunt;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

/**
 * 管理用例运行结果的表
 */
@Mapper
public interface MgCaseRuntInter {
    @Insert("insert into caserunt(caseid,taskid,casename,taskname,status,createtime,updatetime) " +
            "values (#{param.caseid},#{param.taskid},#{param.casename},#{param.taskname},#{param.status},now(),now())")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void addcaserunt(@Param(value = "param") Caserunt caserunt);

    @Update("update caserunt set status=#{status},updatetime=#{updatetime} where id=#{id}")
    void upstatuscaserunt(@Param(value = "id") int id,
                          @Param(value = "status") int status,
                          @Param(value = "updatetime")Date updatetime);


    @Select("select * from caserunt where taskid in (select id from runtasktable " +
            "where projectid=#{projectid}) order by createtime desc limit #{startnum},20")
    List<Caserunt> getCaserunt(@Param(value = "projectid") int projectid,@Param(value = "startnum") int startnum);
}
